<template>
  <div class="article-comment">

    <!-- 全部评论 -->
    <van-sticky offset-top="11.73333vw">
      <div class="title van-hairline--bottom">
        <span>全部评论 ({{ list.length }})</span>
        <span>{{ details.like_count }}点赞</span>
      </div>
    </van-sticky>
    <!-- 评论列表 -->
    <van-empty v-if="list.length? false : true  " description="还没有人评论哦" />
    <div class="list" v-else>
      <div class="item van-hairline--bottom" v-for="item in list" :key="item.aut_id">
        <van-image round width="10vw" height="10vw" src="https://img01.yzcdn.cn/vant/cat.jpeg"/>
        <div class="info">
          <p>
            <span class="name">{{ item.aut_name }}</span>
            <span class="zan"> {{ item.like_count }} </span>
          </p>
          <p class="cont">{{ item.content }}</p>
          <p>
            <span class="reply">回复 <i class="van-icon van-icon-arrow"></i></span>
            <span class="time">{{item.pubdate}}</span>
          </p>
        </div>
      </div>
    </div>
    <!-- 底部工具 -->

  </div>
</template>
<script>
import { Artcomments } from '@/api/user'
export default {
  name: 'ArticleComment',
  props: {
    id: {
      type: String,
      required: true
    },
    details: {
      type: Object,
      required: true
    }
  },
  data () {
    return {
      list: []
    }
  },
  async created () {
    const res = await Artcomments({ type: 'a', source: +this.id })
    console.log(res)
    this.list = res.data.results
  }
}
</script>
<style scoped lang="less">
.article-comment {
  .title {
    height: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    background: #fff;
    span {
      font-size: 16px;
      &:last-child {
        color: #ccc;
        font-size: 14px;
      }
    }
  }
  .list {
    padding: 0 16px;
    margin-bottom:50px;
    .item {
      display: flex;
      padding: 10px 0;
      .info {
        padding-left: 10px;
        flex: 1;
        p {
          margin: 0;
          .name {
            font-size: 16px;
          }
          .zan {
            font-size: 14px;
            float: right;
            color: #999;
            .geek-icon {
              font-size: 12px;
              position: relative;
              top: -1px;
            }
          }
          &.cont {
            font-size: 14px;
            color: #666;
            padding: 10px 0;
            word-break: break-all;
            padding-right: 40px;
          }
          .reply {
            min-width: 60px;
            height: 24px;
            text-align: center;
            line-height: 28px;
            font-size: 12px;
            // background: @geek-gray-color;
            display: inline-block;
            border-radius: 14px;
            color: #666;
            .van-icon {
              position: relative;
              top: 1px;
            }
          }
          .time {
            font-size: 12px;
            color: #999;
            margin-left: 10px;
          }
        }
      }
    }
  }
}
</style>
